const Mock = require('./mock')
const image = '/images/demo.png'

function mockRequest(params) {
	if (!params.size) {
		params.size = 10
	}
	const {
		size,
		current,
		type
	} = params
	try {
		let command = {
			correlation:()=>{
							/* 获取关联服务项目 */
				let mockParams = {
					"code": "200",
					"msg": '',
					"pageSize": 10,
					"total": 0,
					"current": 1,
					"data": [{
						title:"企业维保",model:"maintenance",
						path:"/pages/maintenance/maintenance",
						image:image,
						desc:['@ctitle(4,6)','@ctitle(4,6)','@ctitle(4,6)'], //描述
					}, {
						title:"应学堂",model:"school",
						path:"/pages/school/school",
						image:image,
						desc:['@ctitle(4,6)','@ctitle(4,6)','@ctitle(4,6)'], //描述
					}, {
						title:"应商城",model:"mall",
						path:"/pages/mall/mall",
						image:image,
						desc:['@ctitle(4,6)','@ctitle(4,6)','@ctitle(4,6)'], //描述
					}, {
						title:"应生活",model:"life",
						path:"/pages/life/life",
						image:image,
						desc:['@ctitle(4,6)','@ctitle(4,6)','@ctitle(4,6)'], //描述
					}],
				}
				
				let res = Mock.mock(mockParams)
				params?.success(res)	
			},
			activity: () => {
				/* 获取推荐项目 */
				let mockParams = {
					"code": "200",
					"msg": '',
					"pageSize": 10,
					"total": 0,
					"current": 1,
				}
				mockParams[`data|${size}`] = [{
					'id|+1': 1,
					mainImage: image,
					moreImage: [image, image, image, image],
					"status": '@Boolean(1,9,true)', //是否展示在页面中 查询时不返回为false的数据
					"fixedPrice": '@Boolean(1,9)', //一口价
					'title': '@ctitle(6,30)', //名称
					"serve_price": '@integer(0)', //服务费-上门费
					'originalPrice': '@integer(600,2000)', // 原价/划线价格
					'sellingPrice': '@integer(200,500)', //销售价格/实际价格
					'createdTime': '@now()', //创建时间
				}]
				let res = Mock.mock(mockParams)
				params?.success(res)
			},
			menus: () => {
				/* 获取推荐项目 */
				let mockParams = {
					"code": "200",
					"msg": '',
					"pageSize": 10,
					"total": 0,
					"current": 1,
				}
				mockParams[`data|${size}`] = [{
					'id|+1': 1,
					'title': '@ctitle(4)', //分类名称 //最多五个字
					image: image, //分类图片
					"status": '@Boolean(1,9,true)', //是否展示在页面中 查询时不返回为false的数据
					children: [{
						parent: 1, //关联父级ID
						image,
						id:"@ctitle(4,6)",
						title: '@ctitle(4)',//最多五个字
						"status": '@Boolean(1,9,true)', //是否展示在页面中 查询时不返回为false的数据
					},{
						parent: 1, //关联父级ID
						image,
						title: '@ctitle(4)',
						id:"@ctitle(4,6)",
						"status": '@Boolean(1,9,true)', //是否展示在页面中 查询时不返回为false的数据
					}], //关联分类
				}]
				let res = Mock.mock(mockParams)
				params?.success(res)
			}
		}
		return command[type]()
	} catch (e) {
		console.error('mockRequest======', e)
	}



}
export default mockRequest